#ifndef TABLEMODEL_H
#define TABLEMODEL_H

#include <QtGui>

#include "Field.h"
#include "Object.h"

  // used for testing by QtGraphics
class TableModel : public QAbstractTableModel
{
    public:
    TableModel( int nRows = Field::HEIGHT, int nColumns = Field::WIDTH, QObject* pobj = 0 )
             : QAbstractTableModel( pobj ),
               m_nRows( nRows ),
               m_nColumns( nColumns )
         {}

         QVariant data( const QModelIndex& index, int nRole ) const;
         bool setData( const QModelIndex &index, const QVariant &value, int role );

         int rowCount( const QModelIndex& ) const{ return m_nRows; }
         int columnCount( const QModelIndex& ) const{ return m_nColumns; }

         Qt::ItemFlags flags( const QModelIndex& index ) const{
             Qt::ItemFlags flags = QAbstractTableModel::flags( index );
             return index.isValid() ? ( flags | Qt::ItemIsEditable )
                                    : flags;
         }

         QModelIndex genIndex( int row, int colomn, int nRole = 0 ){
              return createIndex( row, colomn, nRole );
         }
    protected:
    private:
         int m_nRows;
         int m_nColumns;

         QHash<QModelIndex, QVariant> m_hash;
};

#endif // TABLEMODEL_H
